using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using ns18;
using ns20;

namespace ns16
{
	internal class Class137 : Class136
	{
		internal enum Enum16
		{
			None,
			Null,
			Value
		}

		private Class113 class113_0;

		private Class90 class90_0;

		[CompilerGenerated]
		private static Func<ParameterInfo, ParameterInfo> func_0;

		[CompilerGenerated]
		private static Func<ParameterInfo, object> func_1;

		[CompilerGenerated]
		private static Func<KeyValuePair<ParameterInfo, object>, string> func_2;

		[CompilerGenerated]
		private static Func<JsonProperty, JsonProperty> func_3;

		[CompilerGenerated]
		private static Func<JsonProperty, Enum16> func_4;

		public Class137(JsonSerializer serializer)
			: base(serializer)
		{
		}

		public void method_3(JsonReader jsonReader_0, object object_0)
		{
			Class204.smethod_2(object_0, "target");
			Type type = object_0.GetType();
			JsonContract jsonContract = jsonSerializer_0.icontractResolver_0.ResolveContract(type);
			if (jsonReader_0.JsonToken_0 == JsonToken.None)
			{
				jsonReader_0.Read();
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.StartArray)
			{
				if (jsonContract.enum15_0 == Enum15.Array)
				{
					JsonArrayContract jsonArrayContract = (JsonArrayContract)jsonContract;
					method_32(jsonArrayContract.Boolean_0 ? jsonArrayContract.method_5(object_0) : ((IList)object_0), jsonReader_0, jsonArrayContract, null, null);
					return;
				}
				throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot populate JSON array onto type '{0}'.".smethod_0(CultureInfo.InvariantCulture, type));
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.StartObject)
			{
				method_16(jsonReader_0);
				string string_ = null;
				if (jsonReader_0.JsonToken_0 == JsonToken.PropertyName && string.Equals(jsonReader_0.Object_0.ToString(), "$id", StringComparison.Ordinal))
				{
					method_16(jsonReader_0);
					string_ = ((jsonReader_0.Object_0 != null) ? jsonReader_0.Object_0.ToString() : null);
					method_16(jsonReader_0);
				}
				if (jsonContract.enum15_0 == Enum15.Dictionary)
				{
					JsonDictionaryContract jsonDictionaryContract = (JsonDictionaryContract)jsonContract;
					method_29(jsonDictionaryContract.Boolean_0 ? jsonDictionaryContract.method_5(object_0) : ((IDictionary)object_0), jsonReader_0, jsonDictionaryContract, null, string_);
					return;
				}
				if (jsonContract.enum15_0 != Enum15.Object)
				{
					throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot populate JSON object onto type '{0}'.".smethod_0(CultureInfo.InvariantCulture, type));
				}
				method_40(object_0, jsonReader_0, (JsonObjectContract)jsonContract, null, string_);
				return;
			}
			throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected initial token '{0}' when populating object. Expected JSON object or array.".smethod_0(CultureInfo.InvariantCulture, jsonReader_0.JsonToken_0));
		}

		private JsonContract method_4(Type type_0)
		{
			if (type_0 == null)
			{
				return null;
			}
			return jsonSerializer_0.icontractResolver_0.ResolveContract(type_0);
		}

		public object method_5(JsonReader jsonReader_0, Type type_0, bool bool_1)
		{
			if (jsonReader_0 == null)
			{
				throw new ArgumentNullException("reader");
			}
			JsonContract jsonContract = method_4(type_0);
			try
			{
				JsonConverter jsonConverter = method_12(jsonContract, null, null, null);
				if (jsonReader_0.JsonToken_0 == JsonToken.None && !method_38(jsonReader_0, jsonContract, jsonConverter != null))
				{
					if (jsonContract != null && !jsonContract.bool_0)
					{
						throw JsonSerializationException.smethod_1(jsonReader_0, "No JSON content found and type '{0}' is not nullable.".smethod_0(CultureInfo.InvariantCulture, jsonContract.UnderlyingType));
					}
					return null;
				}
				object result = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, type_0, jsonContract, null, null, null, null) : method_36(jsonConverter, jsonReader_0, type_0, null));
				if (bool_1 && jsonReader_0.Read() && jsonReader_0.JsonToken_0 != JsonToken.Comment)
				{
					throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object.");
				}
				return result;
			}
			catch (Exception exception_)
			{
				if (!method_2(null, jsonContract, null, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
				{
					throw;
				}
				method_44(jsonReader_0, bool_1: false, 0);
				return null;
			}
		}

		private Class113 method_6()
		{
			if (class113_0 == null)
			{
				class113_0 = new Class113(this);
			}
			return class113_0;
		}

		private Class90 method_7()
		{
			if (class90_0 == null)
			{
				class90_0 = new Class90(method_6());
			}
			return class90_0;
		}

		private JToken method_8(JsonReader jsonReader_0, JsonContract jsonContract_0)
		{
			Class204.smethod_2(jsonReader_0, "reader");
			if (jsonContract_0 != null && jsonContract_0.UnderlyingType == typeof(JRaw))
			{
				return JRaw.Create(jsonReader_0);
			}
			using JTokenWriter jTokenWriter = new JTokenWriter();
			jTokenWriter.WriteToken(jsonReader_0);
			return jTokenWriter.Token;
		}

		private JToken method_9(JsonReader jsonReader_0)
		{
			Class204.smethod_2(jsonReader_0, "reader");
			using JTokenWriter jTokenWriter = new JTokenWriter();
			jTokenWriter.WriteStartObject();
			if (jsonReader_0.JsonToken_0 == JsonToken.PropertyName)
			{
				jTokenWriter.method_5(jsonReader_0, jsonReader_0.Int32_0 - 1, bool_1: true, bool_2: true);
			}
			else
			{
				jTokenWriter.WriteEndObject();
			}
			return jTokenWriter.Token;
		}

		private object method_10(JsonReader jsonReader_0, Type type_0, JsonContract jsonContract_0, JsonProperty jsonProperty_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1, object object_0)
		{
			if (jsonContract_0 != null && jsonContract_0.enum15_0 == Enum15.Linq)
			{
				return method_8(jsonReader_0, jsonContract_0);
			}
			do
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.Comment:
					break;
				case JsonToken.StartObject:
					return method_13(jsonReader_0, type_0, jsonContract_0, jsonProperty_0, jsonContainerContract_0, jsonProperty_1, object_0);
				case JsonToken.StartArray:
					return method_17(jsonReader_0, type_0, jsonContract_0, jsonProperty_0, object_0, null);
				case JsonToken.StartConstructor:
				{
					string object_ = jsonReader_0.Object_0.ToString();
					return method_19(jsonReader_0, object_, CultureInfo.InvariantCulture, jsonContract_0, type_0);
				}
				case JsonToken.Raw:
					return new JRaw((string)jsonReader_0.Object_0);
				case JsonToken.String:
				{
					string text = (string)jsonReader_0.Object_0;
					if (string.IsNullOrEmpty(text) && type_0 != typeof(string) && type_0 != typeof(object) && jsonContract_0 != null && jsonContract_0.bool_0)
					{
						return null;
					}
					if (type_0 == typeof(byte[]))
					{
						return Convert.FromBase64String(text);
					}
					return method_19(jsonReader_0, text, CultureInfo.InvariantCulture, jsonContract_0, type_0);
				}
				case JsonToken.Null:
				case JsonToken.Undefined:
					if (type_0 == typeof(DBNull))
					{
						return DBNull.Value;
					}
					return method_19(jsonReader_0, jsonReader_0.Object_0, CultureInfo.InvariantCulture, jsonContract_0, type_0);
				default:
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token while deserializing object: " + jsonReader_0.JsonToken_0);
				case JsonToken.Integer:
				case JsonToken.Float:
				case JsonToken.Boolean:
				case JsonToken.Date:
				case JsonToken.Bytes:
					return method_19(jsonReader_0, jsonReader_0.Object_0, CultureInfo.InvariantCulture, jsonContract_0, type_0);
				}
			}
			while (jsonReader_0.Read());
			throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when deserializing object.");
		}

		internal string method_11(JsonContract jsonContract_0)
		{
			switch (jsonContract_0.enum15_0)
			{
			default:
				throw new ArgumentOutOfRangeException();
			case Enum15.Array:
				return "JSON array (e.g. [1,2,3])";
			case Enum15.Primitive:
				return "JSON primitive value (e.g. string, number, boolean, null)";
			case Enum15.String:
				return "JSON string value";
			case Enum15.Object:
			case Enum15.Dictionary:
			case Enum15.Dynamic:
			case Enum15.Serializable:
				return "JSON object (e.g. {\"name\":\"value\"})";
			}
		}

		private JsonConverter method_12(JsonContract jsonContract_0, JsonConverter jsonConverter_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_0)
		{
			JsonConverter result = null;
			if (jsonConverter_0 != null)
			{
				result = jsonConverter_0;
			}
			else if (jsonProperty_0 != null && jsonProperty_0.ItemConverter != null)
			{
				result = jsonProperty_0.ItemConverter;
			}
			else if (jsonContainerContract_0 != null && jsonContainerContract_0.ItemConverter != null)
			{
				result = jsonContainerContract_0.ItemConverter;
			}
			else if (jsonContract_0 != null)
			{
				JsonConverter jsonConverter;
				if (jsonContract_0.Converter != null)
				{
					result = jsonContract_0.Converter;
				}
				else if ((jsonConverter = jsonSerializer_0.method_2(jsonContract_0.UnderlyingType)) != null)
				{
					result = jsonConverter;
				}
				else if (jsonContract_0.JsonConverter_0 != null)
				{
					result = jsonContract_0.JsonConverter_0;
				}
			}
			return result;
		}

		private object method_13(JsonReader jsonReader_0, Type type_0, JsonContract jsonContract_0, JsonProperty jsonProperty_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1, object object_0)
		{
			method_16(jsonReader_0);
			if (method_14(jsonReader_0, ref type_0, ref jsonContract_0, jsonProperty_0, jsonContainerContract_0, jsonProperty_1, object_0, out var object_, out var string_))
			{
				return object_;
			}
			if (method_18(jsonContract_0))
			{
				return method_9(jsonReader_0);
			}
			switch (jsonContract_0.enum15_0)
			{
			case Enum15.Object:
			{
				bool bool_2 = false;
				JsonObjectContract jsonObjectContract_ = (JsonObjectContract)jsonContract_0;
				object obj = ((object_0 == null) ? method_39(jsonReader_0, jsonObjectContract_, jsonProperty_0, jsonProperty_1, string_, out bool_2) : object_0);
				if (bool_2)
				{
					return obj;
				}
				return method_40(obj, jsonReader_0, jsonObjectContract_, jsonProperty_0, string_);
			}
			case Enum15.Primitive:
			{
				JsonPrimitiveContract jsonContract_ = (JsonPrimitiveContract)jsonContract_0;
				if (jsonReader_0.JsonToken_0 == JsonToken.PropertyName && string.Equals(jsonReader_0.Object_0.ToString(), "$value", StringComparison.Ordinal))
				{
					method_16(jsonReader_0);
					if (jsonReader_0.JsonToken_0 == JsonToken.StartObject)
					{
						throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing primitive value: " + jsonReader_0.JsonToken_0);
					}
					object result = method_10(jsonReader_0, type_0, jsonContract_, jsonProperty_0, null, null, object_0);
					method_16(jsonReader_0);
					return result;
				}
				goto default;
			}
			default:
				throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot deserialize the current JSON object (e.g. {{\"name\":\"value\"}}) into type '{0}' because the type requires a {1} to deserialize correctly.\r\nTo fix this error either change the JSON to a {1} or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\n".smethod_1(CultureInfo.InvariantCulture, type_0, method_11(jsonContract_0)));
			case Enum15.Dictionary:
			{
				JsonDictionaryContract jsonDictionaryContract = (JsonDictionaryContract)jsonContract_0;
				if (object_0 == null)
				{
					bool bool_;
					IDictionary dictionary = method_26(jsonReader_0, jsonDictionaryContract, out bool_);
					if (string_ != null && bool_)
					{
						throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot preserve reference to readonly dictionary, or dictionary created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
					}
					if (jsonContract_0.OnSerializingCallbacks.Count > 0 && bool_)
					{
						throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot call OnSerializing on readonly dictionary, or dictionary created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
					}
					if (jsonContract_0.OnErrorCallbacks.Count > 0 && bool_)
					{
						throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot call OnError on readonly list, or dictionary created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
					}
					method_29(dictionary, jsonReader_0, jsonDictionaryContract, jsonProperty_0, string_);
					if (bool_)
					{
						return jsonDictionaryContract.ConstructorInfo_0.Invoke(new object[1] { dictionary });
					}
					if (dictionary is Interface16)
					{
						return ((Interface16)dictionary).Object_0;
					}
					return dictionary;
				}
				return method_29(jsonDictionaryContract.Boolean_0 ? jsonDictionaryContract.method_5(object_0) : ((IDictionary)object_0), jsonReader_0, jsonDictionaryContract, jsonProperty_0, string_);
			}
			case Enum15.Dynamic:
			{
				JsonDynamicContract jsonDynamicContract_ = (JsonDynamicContract)jsonContract_0;
				return method_34(jsonReader_0, jsonDynamicContract_, jsonProperty_0, string_);
			}
			case Enum15.Serializable:
			{
				JsonISerializableContract jsonISerializableContract_ = (JsonISerializableContract)jsonContract_0;
				return method_33(jsonReader_0, jsonISerializableContract_, jsonProperty_0, string_);
			}
			}
		}

		private bool method_14(JsonReader jsonReader_0, ref Type type_0, ref JsonContract jsonContract_0, JsonProperty jsonProperty_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1, object object_0, out object object_1, out string string_0)
		{
			string_0 = null;
			object_1 = null;
			if (jsonReader_0.JsonToken_0 == JsonToken.PropertyName)
			{
				string text = jsonReader_0.Object_0.ToString();
				if (text.Length > 0 && text[0] == '$')
				{
					bool flag;
					do
					{
						text = jsonReader_0.Object_0.ToString();
						if (!string.Equals(text, "$ref", StringComparison.Ordinal))
						{
							if (string.Equals(text, "$type", StringComparison.Ordinal))
							{
								method_16(jsonReader_0);
								string text2 = jsonReader_0.Object_0.ToString();
								if ((jsonProperty_0?.TypeNameHandling ?? jsonContainerContract_0?.ItemTypeNameHandling ?? jsonProperty_1?.ItemTypeNameHandling ?? jsonSerializer_0.typeNameHandling_0) != 0)
								{
									Class195.smethod_32(text2, out var string_, out var string_2);
									Type type;
									try
									{
										type = jsonSerializer_0.serializationBinder_0.BindToType(string_2, string_);
									}
									catch (Exception exception_)
									{
										throw JsonSerializationException.smethod_2(jsonReader_0, "Error resolving type specified in JSON '{0}'.".smethod_0(CultureInfo.InvariantCulture, text2), exception_);
									}
									if (type == null)
									{
										throw JsonSerializationException.smethod_1(jsonReader_0, "Type specified in JSON '{0}' was not resolved.".smethod_0(CultureInfo.InvariantCulture, text2));
									}
									if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
									{
										itraceWriter_0.Trace(TraceLevel.Verbose, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Resolved type '{0}' to {1}.".smethod_1(CultureInfo.InvariantCulture, text2, type)), null);
									}
									if (type_0 != null && type_0 != typeof(IDynamicMetaObjectProvider) && !type_0.IsAssignableFrom(type))
									{
										throw JsonSerializationException.smethod_1(jsonReader_0, "Type specified in JSON '{0}' is not compatible with '{1}'.".smethod_1(CultureInfo.InvariantCulture, type.AssemblyQualifiedName, type_0.AssemblyQualifiedName));
									}
									type_0 = type;
									jsonContract_0 = method_4(type);
								}
								method_16(jsonReader_0);
								flag = true;
							}
							else if (string.Equals(text, "$id", StringComparison.Ordinal))
							{
								method_16(jsonReader_0);
								string_0 = ((jsonReader_0.Object_0 != null) ? jsonReader_0.Object_0.ToString() : null);
								method_16(jsonReader_0);
								flag = true;
							}
							else
							{
								if (string.Equals(text, "$values", StringComparison.Ordinal))
								{
									method_16(jsonReader_0);
									object obj = method_17(jsonReader_0, type_0, jsonContract_0, jsonProperty_0, object_0, string_0);
									method_16(jsonReader_0);
									object_1 = obj;
									return true;
								}
								flag = false;
							}
							continue;
						}
						method_16(jsonReader_0);
						if (jsonReader_0.JsonToken_0 == JsonToken.String || jsonReader_0.JsonToken_0 == JsonToken.Null)
						{
							string text3 = ((jsonReader_0.Object_0 != null) ? jsonReader_0.Object_0.ToString() : null);
							method_16(jsonReader_0);
							if (text3 == null)
							{
								flag = true;
								continue;
							}
							if (jsonReader_0.JsonToken_0 == JsonToken.PropertyName)
							{
								throw JsonSerializationException.smethod_1(jsonReader_0, "Additional content found in JSON reference object. A JSON reference object should only have a {0} property.".smethod_0(CultureInfo.InvariantCulture, "$ref"));
							}
							object_1 = jsonSerializer_0.method_1().ResolveReference(this, text3);
							if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
							{
								itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Resolved object reference '{0}' to {1}.".smethod_1(CultureInfo.InvariantCulture, text3, object_1.GetType())), null);
							}
							return true;
						}
						throw JsonSerializationException.smethod_1(jsonReader_0, "JSON reference {0} property must have a string or null value.".smethod_0(CultureInfo.InvariantCulture, "$ref"));
					}
					while (flag && jsonReader_0.JsonToken_0 == JsonToken.PropertyName);
				}
			}
			return false;
		}

		private JsonArrayContract method_15(JsonReader jsonReader_0, Type type_0, JsonContract jsonContract_0)
		{
			if (jsonContract_0 == null)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Could not resolve type '{0}' to a JsonContract.".smethod_0(CultureInfo.InvariantCulture, type_0));
			}
			JsonArrayContract jsonArrayContract = jsonContract_0 as JsonArrayContract;
			if (jsonArrayContract == null)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type '{0}' because the type requires a {1} to deserialize correctly.\r\nTo fix this error either change the JSON to a {1} or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\n".smethod_1(CultureInfo.InvariantCulture, type_0, method_11(jsonContract_0)));
			}
			return jsonArrayContract;
		}

		private void method_16(JsonReader jsonReader_0)
		{
			if (!jsonReader_0.Read())
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when deserializing object.");
			}
		}

		private object method_17(JsonReader jsonReader_0, Type type_0, JsonContract jsonContract_0, JsonProperty jsonProperty_0, object object_0, string string_0)
		{
			if (method_18(jsonContract_0))
			{
				return method_8(jsonReader_0, jsonContract_0);
			}
			JsonArrayContract jsonArrayContract = method_15(jsonReader_0, type_0, jsonContract_0);
			if (object_0 == null)
			{
				bool bool_;
				IList list = method_25(jsonReader_0, jsonArrayContract, out bool_);
				if (string_0 != null && bool_)
				{
					throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot preserve reference to array or readonly list, or list created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
				}
				if (jsonContract_0.OnSerializingCallbacks.Count > 0 && bool_)
				{
					throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot call OnSerializing on an array or readonly list, or list created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
				}
				if (jsonContract_0.OnErrorCallbacks.Count > 0 && bool_)
				{
					throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot call OnError on an array or readonly list, or list created from a non-default constructor: {0}.".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType));
				}
				if (!jsonArrayContract.IsMultidimensionalArray)
				{
					method_32(list, jsonReader_0, jsonArrayContract, jsonProperty_0, string_0);
				}
				else
				{
					method_30(list, jsonReader_0, jsonArrayContract, jsonProperty_0, string_0);
				}
				if (bool_)
				{
					if (jsonArrayContract.IsMultidimensionalArray)
					{
						list = Class192.smethod_13(list, jsonArrayContract.CollectionItemType, jsonContract_0.CreatedType.GetArrayRank());
					}
					else
					{
						if (!jsonContract_0.CreatedType.IsArray)
						{
							return jsonArrayContract.ConstructorInfo_0.Invoke(new object[1] { list });
						}
						Array array = Array.CreateInstance(jsonArrayContract.CollectionItemType, list.Count);
						list.CopyTo(array, 0);
						list = array;
					}
				}
				else if (list is Interface15)
				{
					return ((Interface15)list).Object_0;
				}
				return list;
			}
			return method_32(jsonArrayContract.Boolean_0 ? jsonArrayContract.method_5(object_0) : ((IList)object_0), jsonReader_0, jsonArrayContract, jsonProperty_0, string_0);
		}

		private bool method_18(JsonContract jsonContract_0)
		{
			if (jsonContract_0 != null && !(jsonContract_0.UnderlyingType == typeof(object)) && jsonContract_0.enum15_0 != Enum15.Linq)
			{
				return jsonContract_0.UnderlyingType == typeof(IDynamicMetaObjectProvider);
			}
			return true;
		}

		private object method_19(JsonReader jsonReader_0, object object_0, CultureInfo cultureInfo_0, JsonContract jsonContract_0, Type type_0)
		{
			if (type_0 == null)
			{
				return object_0;
			}
			Type type = Class195.smethod_3(object_0);
			if (type != type_0)
			{
				if (object_0 == null && jsonContract_0.bool_0)
				{
					return null;
				}
				try
				{
					if (jsonContract_0.bool_1)
					{
						JsonPrimitiveContract jsonPrimitiveContract = (JsonPrimitiveContract)jsonContract_0;
						if (jsonContract_0.bool_3)
						{
							if (object_0 is string)
							{
								return Enum.Parse(jsonContract_0.type_0, object_0.ToString(), ignoreCase: true);
							}
							if (Class182.smethod_14(jsonPrimitiveContract.Enum17_0))
							{
								return Enum.ToObject(jsonContract_0.type_0, object_0);
							}
						}
						if (object_0 is BigInteger)
						{
							return Class182.smethod_7((BigInteger)object_0, type_0);
						}
						return Convert.ChangeType(object_0, jsonContract_0.type_0, cultureInfo_0);
					}
					return Class182.smethod_10(object_0, cultureInfo_0, jsonContract_0.type_0);
				}
				catch (Exception exception_)
				{
					throw JsonSerializationException.smethod_2(jsonReader_0, "Error converting value {0} to type '{1}'.".smethod_1(CultureInfo.InvariantCulture, Class194.smethod_7(object_0), type_0), exception_);
				}
			}
			return object_0;
		}

		private bool method_20(JsonProperty jsonProperty_0, JsonConverter jsonConverter_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1, JsonReader jsonReader_0, object object_0)
		{
			if (method_21(jsonProperty_0, ref jsonConverter_0, jsonContainerContract_0, jsonProperty_1, jsonReader_0, object_0, out var bool_, out var object_, out var jsonContract_, out var bool_2))
			{
				return false;
			}
			object obj;
			if (jsonConverter_0 != null && jsonConverter_0.CanRead)
			{
				if (!bool_2 && object_0 != null && jsonProperty_0.Readable)
				{
					object_ = jsonProperty_0.ValueProvider.GetValue(object_0);
				}
				obj = method_36(jsonConverter_0, jsonReader_0, jsonProperty_0.PropertyType, object_);
			}
			else
			{
				obj = method_10(jsonReader_0, jsonProperty_0.PropertyType, jsonContract_, jsonProperty_0, jsonContainerContract_0, jsonProperty_1, bool_ ? object_ : null);
			}
			if ((!bool_ || obj != object_) && method_24(jsonProperty_0, obj))
			{
				jsonProperty_0.ValueProvider.SetValue(object_0, obj);
				if (jsonProperty_0.SetIsSpecified != null)
				{
					if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
					{
						itraceWriter_0.Trace(TraceLevel.Verbose, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "IsSpecified for property '{0}' on {1} set to true.".smethod_1(CultureInfo.InvariantCulture, jsonProperty_0.PropertyName, jsonProperty_0.DeclaringType)), null);
					}
					jsonProperty_0.SetIsSpecified(object_0, true);
				}
				return true;
			}
			return bool_;
		}

		private bool method_21(JsonProperty jsonProperty_0, ref JsonConverter jsonConverter_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1, JsonReader jsonReader_0, object object_0, out bool bool_1, out object object_1, out JsonContract jsonContract_0, out bool bool_2)
		{
			object_1 = null;
			bool_1 = false;
			jsonContract_0 = null;
			bool_2 = false;
			if (jsonProperty_0.Ignored)
			{
				return true;
			}
			JsonToken jsonToken_ = jsonReader_0.JsonToken_0;
			if (jsonProperty_0.JsonContract_0 == null)
			{
				jsonProperty_0.JsonContract_0 = method_4(jsonProperty_0.PropertyType);
			}
			ObjectCreationHandling valueOrDefault = jsonProperty_0.ObjectCreationHandling.GetValueOrDefault(jsonSerializer_0.objectCreationHandling_0);
			if (valueOrDefault != ObjectCreationHandling.Replace && (jsonToken_ == JsonToken.StartArray || jsonToken_ == JsonToken.StartObject) && jsonProperty_0.Readable)
			{
				object_1 = jsonProperty_0.ValueProvider.GetValue(object_0);
				bool_2 = true;
				if (object_1 != null)
				{
					jsonContract_0 = method_4(object_1.GetType());
					bool_1 = !jsonContract_0.bool_4 && !jsonContract_0.UnderlyingType.smethod_12();
				}
			}
			if (!jsonProperty_0.Writable && !bool_1)
			{
				return true;
			}
			if (jsonProperty_0.NullValueHandling.GetValueOrDefault(jsonSerializer_0.nullValueHandling_0) == NullValueHandling.Ignore && jsonToken_ == JsonToken.Null)
			{
				return true;
			}
			if (method_23(jsonProperty_0.DefaultValueHandling.GetValueOrDefault(jsonSerializer_0.defaultValueHandling_0), DefaultValueHandling.Ignore) && !method_23(jsonProperty_0.DefaultValueHandling.GetValueOrDefault(jsonSerializer_0.defaultValueHandling_0), DefaultValueHandling.Populate) && JsonReader.smethod_0(jsonToken_) && Class194.smethod_0(jsonReader_0.Object_0, jsonProperty_0.method_1()))
			{
				return true;
			}
			if (object_1 == null)
			{
				jsonContract_0 = jsonProperty_0.JsonContract_0;
			}
			else
			{
				jsonContract_0 = method_4(object_1.GetType());
				if (jsonContract_0 != jsonProperty_0.JsonContract_0)
				{
					jsonConverter_0 = method_12(jsonContract_0, jsonProperty_0.MemberConverter, jsonContainerContract_0, jsonProperty_1);
				}
			}
			return false;
		}

		private void method_22(JsonReader jsonReader_0, string string_0, object object_0)
		{
			try
			{
				if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
				{
					itraceWriter_0.Trace(TraceLevel.Verbose, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Read object reference Id '{0}' for {1}.".smethod_1(CultureInfo.InvariantCulture, string_0, object_0.GetType())), null);
				}
				jsonSerializer_0.method_1().AddReference(this, string_0, object_0);
			}
			catch (Exception exception_)
			{
				throw JsonSerializationException.smethod_2(jsonReader_0, "Error reading object reference '{0}'.".smethod_0(CultureInfo.InvariantCulture, string_0), exception_);
			}
		}

		private bool method_23(DefaultValueHandling defaultValueHandling_0, DefaultValueHandling defaultValueHandling_1)
		{
			return (defaultValueHandling_0 & defaultValueHandling_1) == defaultValueHandling_1;
		}

		private bool method_24(JsonProperty jsonProperty_0, object object_0)
		{
			if (jsonProperty_0.NullValueHandling.GetValueOrDefault(jsonSerializer_0.nullValueHandling_0) == NullValueHandling.Ignore && object_0 == null)
			{
				return false;
			}
			if (method_23(jsonProperty_0.DefaultValueHandling.GetValueOrDefault(jsonSerializer_0.defaultValueHandling_0), DefaultValueHandling.Ignore) && !method_23(jsonProperty_0.DefaultValueHandling.GetValueOrDefault(jsonSerializer_0.defaultValueHandling_0), DefaultValueHandling.Populate) && Class194.smethod_0(object_0, jsonProperty_0.method_1()))
			{
				return false;
			}
			if (!jsonProperty_0.Writable)
			{
				return false;
			}
			return true;
		}

		private IList method_25(JsonReader jsonReader_0, JsonArrayContract jsonArrayContract_0, out bool bool_1)
		{
			if (!jsonArrayContract_0.Boolean_1)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot create and populate list type {0}.".smethod_0(CultureInfo.InvariantCulture, jsonArrayContract_0.CreatedType));
			}
			if (jsonArrayContract_0.bool_4)
			{
				bool_1 = true;
				IList list = jsonArrayContract_0.method_6();
				if (jsonArrayContract_0.Boolean_0)
				{
					list = jsonArrayContract_0.method_5(list);
				}
				return list;
			}
			if (jsonArrayContract_0.DefaultCreator != null && (!jsonArrayContract_0.DefaultCreatorNonPublic || jsonSerializer_0.constructorHandling_0 == ConstructorHandling.AllowNonPublicDefaultConstructor))
			{
				object obj = jsonArrayContract_0.DefaultCreator();
				if (jsonArrayContract_0.Boolean_0)
				{
					obj = jsonArrayContract_0.method_5(obj);
				}
				bool_1 = false;
				return (IList)obj;
			}
			if (!(jsonArrayContract_0.ConstructorInfo_0 != null))
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Unable to find a constructor to use for type {0}.".smethod_0(CultureInfo.InvariantCulture, jsonArrayContract_0.UnderlyingType));
			}
			bool_1 = true;
			return jsonArrayContract_0.method_6();
		}

		private IDictionary method_26(JsonReader jsonReader_0, JsonDictionaryContract jsonDictionaryContract_0, out bool bool_1)
		{
			if (jsonDictionaryContract_0.bool_4)
			{
				bool_1 = true;
				return jsonDictionaryContract_0.method_6();
			}
			if (jsonDictionaryContract_0.DefaultCreator != null && (!jsonDictionaryContract_0.DefaultCreatorNonPublic || jsonSerializer_0.constructorHandling_0 == ConstructorHandling.AllowNonPublicDefaultConstructor))
			{
				object obj = jsonDictionaryContract_0.DefaultCreator();
				if (jsonDictionaryContract_0.Boolean_0)
				{
					obj = jsonDictionaryContract_0.method_5(obj);
				}
				bool_1 = false;
				return (IDictionary)obj;
			}
			if (!(jsonDictionaryContract_0.ConstructorInfo_0 != null))
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Unable to find a default constructor to use for type {0}.".smethod_0(CultureInfo.InvariantCulture, jsonDictionaryContract_0.UnderlyingType));
			}
			bool_1 = true;
			return jsonDictionaryContract_0.method_6();
		}

		private void method_27(JsonReader jsonReader_0, JsonContract jsonContract_0, object object_0)
		{
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Started deserializing {0}".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType)), null);
			}
			jsonContract_0.method_2(object_0, jsonSerializer_0.streamingContext_0);
		}

		private void method_28(JsonReader jsonReader_0, JsonContract jsonContract_0, object object_0)
		{
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Finished deserializing {0}".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType)), null);
			}
			jsonContract_0.method_3(object_0, jsonSerializer_0.streamingContext_0);
		}

		private object method_29(IDictionary idictionary_0, JsonReader jsonReader_0, JsonDictionaryContract jsonDictionaryContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			Interface16 @interface = idictionary_0 as Interface16;
			object obj = ((@interface != null) ? @interface.Object_0 : idictionary_0);
			if (string_0 != null)
			{
				method_22(jsonReader_0, string_0, obj);
			}
			method_27(jsonReader_0, jsonDictionaryContract_0, obj);
			int int32_ = jsonReader_0.Int32_0;
			if (jsonDictionaryContract_0.JsonContract_2 == null)
			{
				jsonDictionaryContract_0.JsonContract_2 = method_4(jsonDictionaryContract_0.DictionaryKeyType);
			}
			if (jsonDictionaryContract_0.JsonContract_0 == null)
			{
				jsonDictionaryContract_0.JsonContract_0 = method_4(jsonDictionaryContract_0.DictionaryValueType);
			}
			JsonConverter jsonConverter = jsonDictionaryContract_0.ItemConverter ?? method_12(jsonDictionaryContract_0.JsonContract_0, null, jsonDictionaryContract_0, jsonProperty_0);
			Enum17 @enum = ((jsonDictionaryContract_0.JsonContract_2 is JsonPrimitiveContract) ? ((JsonPrimitiveContract)jsonDictionaryContract_0.JsonContract_2).Enum17_0 : Enum17.Empty);
			bool flag = false;
			while (true)
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.PropertyName:
				{
					object obj2 = jsonReader_0.Object_0;
					try
					{
						try
						{
							obj2 = (((@enum == Enum17.DateTime || @enum == Enum17.DateTimeNullable) && Class185.smethod_13(obj2.ToString(), DateParseHandling.DateTime, jsonReader_0.DateTimeZoneHandling, out var object_)) ? object_ : (((@enum != Enum17.DateTimeOffset && @enum != Enum17.DateTimeOffsetNullable) || !Class185.smethod_13(obj2.ToString(), DateParseHandling.DateTimeOffset, jsonReader_0.DateTimeZoneHandling, out object_)) ? method_19(jsonReader_0, obj2, CultureInfo.InvariantCulture, jsonDictionaryContract_0.JsonContract_2, jsonDictionaryContract_0.DictionaryKeyType) : object_));
						}
						catch (Exception exception_)
						{
							throw JsonSerializationException.smethod_2(jsonReader_0, "Could not convert string '{0}' to dictionary key type '{1}'. Create a TypeConverter to convert from the string to the key type object.".smethod_1(CultureInfo.InvariantCulture, jsonReader_0.Object_0, jsonDictionaryContract_0.DictionaryKeyType), exception_);
						}
						if (!method_38(jsonReader_0, jsonDictionaryContract_0.JsonContract_0, jsonConverter != null))
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when deserializing object.");
						}
						object obj4 = (idictionary_0[obj2] = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, jsonDictionaryContract_0.DictionaryValueType, jsonDictionaryContract_0.JsonContract_0, null, jsonDictionaryContract_0, jsonProperty_0, null) : method_36(jsonConverter, jsonReader_0, jsonDictionaryContract_0.DictionaryValueType, null)));
					}
					catch (Exception exception_2)
					{
						if (!method_2(obj, jsonDictionaryContract_0, obj2, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_2))
						{
							throw;
						}
						method_44(jsonReader_0, bool_1: true, int32_);
					}
					goto case JsonToken.Comment;
				}
				case JsonToken.EndObject:
					flag = true;
					goto case JsonToken.Comment;
				case JsonToken.Comment:
					if (flag || !jsonReader_0.Read())
					{
						if (!flag)
						{
							method_31(jsonReader_0, jsonDictionaryContract_0, obj, "Unexpected end when deserializing object.");
						}
						method_28(jsonReader_0, jsonDictionaryContract_0, obj);
						return obj;
					}
					break;
				default:
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing object: " + jsonReader_0.JsonToken_0);
				}
			}
		}

		private object method_30(IList ilist_0, JsonReader jsonReader_0, JsonArrayContract jsonArrayContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			int arrayRank = jsonArrayContract_0.UnderlyingType.GetArrayRank();
			if (string_0 != null)
			{
				method_22(jsonReader_0, string_0, ilist_0);
			}
			method_27(jsonReader_0, jsonArrayContract_0, ilist_0);
			JsonContract jsonContract_ = method_4(jsonArrayContract_0.CollectionItemType);
			JsonConverter jsonConverter = method_12(jsonContract_, null, jsonArrayContract_0, jsonProperty_0);
			int? num = null;
			Stack<IList> stack = new Stack<IList>();
			stack.Push(ilist_0);
			IList list = ilist_0;
			bool flag = false;
			do
			{
				int int32_ = jsonReader_0.Int32_0;
				if (stack.Count != arrayRank)
				{
					if (!jsonReader_0.Read())
					{
						break;
					}
					switch (jsonReader_0.JsonToken_0)
					{
					case JsonToken.EndArray:
						stack.Pop();
						if (stack.Count > 0)
						{
							list = stack.Peek();
						}
						else
						{
							flag = true;
						}
						break;
					case JsonToken.StartArray:
					{
						IList list2 = new List<object>();
						list.Add(list2);
						stack.Push(list2);
						list = list2;
						break;
					}
					case JsonToken.Comment:
						break;
					default:
						throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing multidimensional array: " + jsonReader_0.JsonToken_0);
					}
					continue;
				}
				try
				{
					if (method_38(jsonReader_0, jsonContract_, jsonConverter != null))
					{
						switch (jsonReader_0.JsonToken_0)
						{
						case JsonToken.EndArray:
							stack.Pop();
							list = stack.Peek();
							num = null;
							break;
						default:
						{
							object value = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, jsonArrayContract_0.CollectionItemType, jsonContract_, null, jsonArrayContract_0, jsonProperty_0, null) : method_36(jsonConverter, jsonReader_0, jsonArrayContract_0.CollectionItemType, null));
							list.Add(value);
							break;
						}
						case JsonToken.Comment:
							break;
						}
						continue;
					}
				}
				catch (Exception exception_)
				{
					Struct25 @struct = jsonReader_0.method_0(int32_);
					if (method_2(ilist_0, jsonArrayContract_0, @struct.int_0, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
					{
						method_44(jsonReader_0, bool_1: true, int32_);
						if (num.HasValue && num == @struct.int_0)
						{
							throw JsonSerializationException.smethod_2(jsonReader_0, "Infinite loop detected from error handling.", exception_);
						}
						num = @struct.int_0;
						continue;
					}
					throw;
				}
				break;
			}
			while (!flag);
			if (!flag)
			{
				method_31(jsonReader_0, jsonArrayContract_0, ilist_0, "Unexpected end when deserializing array.");
			}
			method_28(jsonReader_0, jsonArrayContract_0, ilist_0);
			return ilist_0;
		}

		private void method_31(JsonReader jsonReader_0, JsonContract jsonContract_0, object object_0, string string_0)
		{
			try
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, string_0);
			}
			catch (Exception exception_)
			{
				if (!method_2(object_0, jsonContract_0, null, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
				{
					throw;
				}
				method_44(jsonReader_0, bool_1: false, 0);
			}
		}

		private object method_32(IList ilist_0, JsonReader jsonReader_0, JsonArrayContract jsonArrayContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			Interface15 @interface = ilist_0 as Interface15;
			object obj = ((@interface != null) ? @interface.Object_0 : ilist_0);
			if (string_0 != null)
			{
				method_22(jsonReader_0, string_0, obj);
			}
			if (ilist_0.IsFixedSize)
			{
				jsonReader_0.Skip();
				return obj;
			}
			method_27(jsonReader_0, jsonArrayContract_0, obj);
			int int32_ = jsonReader_0.Int32_0;
			JsonContract jsonContract_ = method_4(jsonArrayContract_0.CollectionItemType);
			JsonConverter jsonConverter = method_12(jsonContract_, null, jsonArrayContract_0, jsonProperty_0);
			int? num = null;
			bool flag = false;
			do
			{
				try
				{
					if (method_38(jsonReader_0, jsonContract_, jsonConverter != null))
					{
						switch (jsonReader_0.JsonToken_0)
						{
						case JsonToken.EndArray:
							flag = true;
							break;
						default:
						{
							object value = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, jsonArrayContract_0.CollectionItemType, jsonContract_, null, jsonArrayContract_0, jsonProperty_0, null) : method_36(jsonConverter, jsonReader_0, jsonArrayContract_0.CollectionItemType, null));
							ilist_0.Add(value);
							break;
						}
						case JsonToken.Comment:
							break;
						}
						continue;
					}
				}
				catch (Exception exception_)
				{
					Struct25 @struct = jsonReader_0.method_0(int32_);
					if (method_2(obj, jsonArrayContract_0, @struct.int_0, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
					{
						method_44(jsonReader_0, bool_1: true, int32_);
						if (num.HasValue && num == @struct.int_0)
						{
							throw JsonSerializationException.smethod_2(jsonReader_0, "Infinite loop detected from error handling.", exception_);
						}
						num = @struct.int_0;
						continue;
					}
					throw;
				}
				break;
			}
			while (!flag);
			if (!flag)
			{
				method_31(jsonReader_0, jsonArrayContract_0, obj, "Unexpected end when deserializing array.");
			}
			method_28(jsonReader_0, jsonArrayContract_0, obj);
			return obj;
		}

		private object method_33(JsonReader jsonReader_0, JsonISerializableContract jsonISerializableContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			Type underlyingType = jsonISerializableContract_0.UnderlyingType;
			if (!Class140.Boolean_1)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Type '{0}' implements ISerializable but cannot be deserialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data.\r\nTo fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true.\r\n".smethod_0(CultureInfo.InvariantCulture, underlyingType));
			}
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Deserializing {0} using ISerializable constructor.".smethod_0(CultureInfo.InvariantCulture, jsonISerializableContract_0.UnderlyingType)), null);
			}
			SerializationInfo serializationInfo = new SerializationInfo(jsonISerializableContract_0.UnderlyingType, method_7());
			bool flag = false;
			while (true)
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.Comment:
					if (flag || !jsonReader_0.Read())
					{
						if (!flag)
						{
							method_31(jsonReader_0, jsonISerializableContract_0, serializationInfo, "Unexpected end when deserializing object.");
						}
						if (jsonISerializableContract_0.ISerializableCreator == null)
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "ISerializable type '{0}' does not have a valid constructor. To correctly implement ISerializable a constructor that takes SerializationInfo and StreamingContext parameters should be present.".smethod_0(CultureInfo.InvariantCulture, underlyingType));
						}
						object obj = jsonISerializableContract_0.ISerializableCreator(serializationInfo, jsonSerializer_0.streamingContext_0);
						if (string_0 != null)
						{
							method_22(jsonReader_0, string_0, obj);
						}
						method_27(jsonReader_0, jsonISerializableContract_0, obj);
						method_28(jsonReader_0, jsonISerializableContract_0, obj);
						return obj;
					}
					break;
				case JsonToken.PropertyName:
				{
					string text = jsonReader_0.Object_0.ToString();
					if (jsonReader_0.Read())
					{
						if (jsonReader_0.JsonToken_0 == JsonToken.StartObject)
						{
							object value = method_13(jsonReader_0, null, null, null, jsonISerializableContract_0, jsonProperty_0, null);
							serializationInfo.AddValue(text, value);
						}
						else
						{
							serializationInfo.AddValue(text, JToken.ReadFrom(jsonReader_0));
						}
						goto case JsonToken.Comment;
					}
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when setting {0}'s value.".smethod_0(CultureInfo.InvariantCulture, text));
				}
				case JsonToken.EndObject:
					flag = true;
					goto case JsonToken.Comment;
				default:
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing object: " + jsonReader_0.JsonToken_0);
				}
			}
		}

		private object method_34(JsonReader jsonReader_0, JsonDynamicContract jsonDynamicContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			if (!jsonDynamicContract_0.bool_5)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Could not create an instance of type {0}. Type is an interface or abstract class and cannot be instantiated.".smethod_0(CultureInfo.InvariantCulture, jsonDynamicContract_0.UnderlyingType));
			}
			if (jsonDynamicContract_0.DefaultCreator != null && (!jsonDynamicContract_0.DefaultCreatorNonPublic || jsonSerializer_0.constructorHandling_0 == ConstructorHandling.AllowNonPublicDefaultConstructor))
			{
				IDynamicMetaObjectProvider dynamicMetaObjectProvider = (IDynamicMetaObjectProvider)jsonDynamicContract_0.DefaultCreator();
				if (string_0 != null)
				{
					method_22(jsonReader_0, string_0, dynamicMetaObjectProvider);
				}
				method_27(jsonReader_0, jsonDynamicContract_0, dynamicMetaObjectProvider);
				int int32_ = jsonReader_0.Int32_0;
				bool flag = false;
				do
				{
					JsonToken jsonToken_ = jsonReader_0.JsonToken_0;
					if (jsonToken_ == JsonToken.PropertyName)
					{
						string text = jsonReader_0.Object_0.ToString();
						try
						{
							if (!jsonReader_0.Read())
							{
								throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when setting {0}'s value.".smethod_0(CultureInfo.InvariantCulture, text));
							}
							JsonProperty closestMatchProperty = jsonDynamicContract_0.Properties.GetClosestMatchProperty(text);
							if (closestMatchProperty != null && closestMatchProperty.Writable && !closestMatchProperty.Ignored)
							{
								if (closestMatchProperty.JsonContract_0 == null)
								{
									closestMatchProperty.JsonContract_0 = method_4(closestMatchProperty.PropertyType);
								}
								JsonConverter jsonConverter_ = method_12(closestMatchProperty.JsonContract_0, closestMatchProperty.MemberConverter, null, null);
								if (!method_20(closestMatchProperty, jsonConverter_, null, jsonProperty_0, jsonReader_0, dynamicMetaObjectProvider))
								{
									jsonReader_0.Skip();
								}
							}
							else
							{
								Type type_ = (JsonReader.smethod_0(jsonReader_0.JsonToken_0) ? jsonReader_0.Type_0 : typeof(IDynamicMetaObjectProvider));
								JsonContract jsonContract_ = method_4(type_);
								JsonConverter jsonConverter = method_12(jsonContract_, null, null, jsonProperty_0);
								object object_ = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, type_, jsonContract_, null, null, jsonProperty_0, null) : method_36(jsonConverter, jsonReader_0, type_, null));
								jsonDynamicContract_0.method_6(dynamicMetaObjectProvider, text, object_);
							}
						}
						catch (Exception exception_)
						{
							if (!method_2(dynamicMetaObjectProvider, jsonDynamicContract_0, text, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
							{
								throw;
							}
							method_44(jsonReader_0, bool_1: true, int32_);
						}
					}
					else
					{
						if (jsonToken_ != JsonToken.EndObject)
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing object: " + jsonReader_0.JsonToken_0);
						}
						flag = true;
					}
				}
				while (!flag && jsonReader_0.Read());
				if (!flag)
				{
					method_31(jsonReader_0, jsonDynamicContract_0, dynamicMetaObjectProvider, "Unexpected end when deserializing object.");
				}
				method_28(jsonReader_0, jsonDynamicContract_0, dynamicMetaObjectProvider);
				return dynamicMetaObjectProvider;
			}
			throw JsonSerializationException.smethod_1(jsonReader_0, "Unable to find a default constructor to use for type {0}.".smethod_0(CultureInfo.InvariantCulture, jsonDynamicContract_0.UnderlyingType));
		}

		private object method_35(JsonReader jsonReader_0, JsonObjectContract jsonObjectContract_0, JsonProperty jsonProperty_0, ConstructorInfo constructorInfo_0, string string_0)
		{
			Class204.smethod_2(constructorInfo_0, "constructorInfo");
			Type underlyingType = jsonObjectContract_0.UnderlyingType;
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Deserializing {0} using a non-default constructor '{1}'.".smethod_1(CultureInfo.InvariantCulture, jsonObjectContract_0.UnderlyingType, constructorInfo_0)), null);
			}
			IDictionary<JsonProperty, object> dictionary = method_37(jsonObjectContract_0, jsonProperty_0, jsonReader_0, underlyingType);
			IDictionary<ParameterInfo, object> dictionary2 = ((IEnumerable<ParameterInfo>)constructorInfo_0.GetParameters()).ToDictionary((Func<ParameterInfo, ParameterInfo>)((ParameterInfo parameterInfo_0) => parameterInfo_0), (Func<ParameterInfo, object>)((ParameterInfo parameterInfo_0) => null));
			IDictionary<JsonProperty, object> dictionary3 = new Dictionary<JsonProperty, object>();
			foreach (KeyValuePair<JsonProperty, object> item in dictionary)
			{
				ParameterInfo key = dictionary2.smethod_9((KeyValuePair<ParameterInfo, object> keyValuePair_0) => keyValuePair_0.Key.Name, item.Key.UnderlyingName).Key;
				if (key != null)
				{
					dictionary2[key] = item.Value;
				}
				else
				{
					dictionary3.Add(item);
				}
			}
			object obj = constructorInfo_0.Invoke(dictionary2.Values.ToArray());
			if (string_0 != null)
			{
				method_22(jsonReader_0, string_0, obj);
			}
			method_27(jsonReader_0, jsonObjectContract_0, obj);
			foreach (KeyValuePair<JsonProperty, object> item2 in dictionary3)
			{
				JsonProperty key2 = item2.Key;
				object value = item2.Value;
				if (method_24(item2.Key, item2.Value))
				{
					key2.ValueProvider.SetValue(obj, value);
				}
				else
				{
					if (key2.Writable || value == null)
					{
						continue;
					}
					JsonContract jsonContract = jsonSerializer_0.icontractResolver_0.ResolveContract(key2.PropertyType);
					if (jsonContract.enum15_0 == Enum15.Array)
					{
						JsonArrayContract jsonArrayContract = (JsonArrayContract)jsonContract;
						object value2 = key2.ValueProvider.GetValue(obj);
						if (value2 == null)
						{
							continue;
						}
						Interface15 @interface = jsonArrayContract.method_5(value2);
						Interface15 interface2 = jsonArrayContract.method_5(value);
						foreach (object item3 in interface2)
						{
							@interface.Add(item3);
						}
					}
					else
					{
						if (jsonContract.enum15_0 != Enum15.Dictionary)
						{
							continue;
						}
						JsonDictionaryContract jsonDictionaryContract = (JsonDictionaryContract)jsonContract;
						object value3 = key2.ValueProvider.GetValue(obj);
						if (value3 == null)
						{
							continue;
						}
						IDictionary dictionary4 = (jsonDictionaryContract.Boolean_0 ? jsonDictionaryContract.method_5(value3) : ((IDictionary)value3));
						IDictionary dictionary5 = (jsonDictionaryContract.Boolean_0 ? jsonDictionaryContract.method_5(value) : ((IDictionary)value));
						foreach (DictionaryEntry item4 in dictionary5)
						{
							dictionary4.Add(item4.Key, item4.Value);
						}
					}
				}
			}
			method_28(jsonReader_0, jsonObjectContract_0, obj);
			return obj;
		}

		private object method_36(JsonConverter jsonConverter_0, JsonReader jsonReader_0, Type type_0, object object_0)
		{
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Started deserializing {0} with converter {1}.".smethod_1(CultureInfo.InvariantCulture, type_0, jsonConverter_0.GetType())), null);
			}
			object result = jsonConverter_0.ReadJson(jsonReader_0, type_0, object_0, method_6());
			if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Info)
			{
				itraceWriter_0.Trace(TraceLevel.Info, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Finished deserializing {0} with converter {1}.".smethod_1(CultureInfo.InvariantCulture, type_0, jsonConverter_0.GetType())), null);
			}
			return result;
		}

		private IDictionary<JsonProperty, object> method_37(JsonObjectContract jsonObjectContract_0, JsonProperty jsonProperty_0, JsonReader jsonReader_0, Type type_0)
		{
			IDictionary<JsonProperty, object> dictionary = new Dictionary<JsonProperty, object>();
			bool flag = false;
			while (true)
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.Comment:
					if (flag || !jsonReader_0.Read())
					{
						return dictionary;
					}
					break;
				case JsonToken.PropertyName:
				{
					string text = jsonReader_0.Object_0.ToString();
					JsonProperty jsonProperty = jsonObjectContract_0.ConstructorParameters.GetClosestMatchProperty(text) ?? jsonObjectContract_0.Properties.GetClosestMatchProperty(text);
					if (jsonProperty != null)
					{
						if (jsonProperty.JsonContract_0 == null)
						{
							jsonProperty.JsonContract_0 = method_4(jsonProperty.PropertyType);
						}
						JsonConverter jsonConverter = method_12(jsonProperty.JsonContract_0, jsonProperty.MemberConverter, jsonObjectContract_0, jsonProperty_0);
						if (!method_38(jsonReader_0, jsonProperty.JsonContract_0, jsonConverter != null))
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when setting {0}'s value.".smethod_0(CultureInfo.InvariantCulture, text));
						}
						if (!jsonProperty.Ignored)
						{
							if (jsonProperty.JsonContract_0 == null)
							{
								jsonProperty.JsonContract_0 = method_4(jsonProperty.PropertyType);
							}
							object obj2 = (dictionary[jsonProperty] = ((jsonConverter == null || !jsonConverter.CanRead) ? method_10(jsonReader_0, jsonProperty.PropertyType, jsonProperty.JsonContract_0, jsonProperty, jsonObjectContract_0, jsonProperty_0, null) : method_36(jsonConverter, jsonReader_0, jsonProperty.PropertyType, null)));
						}
						else
						{
							jsonReader_0.Skip();
						}
					}
					else
					{
						if (!jsonReader_0.Read())
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when setting {0}'s value.".smethod_0(CultureInfo.InvariantCulture, text));
						}
						if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
						{
							itraceWriter_0.Trace(TraceLevel.Verbose, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Could not find member '{0}' on {1}.".smethod_1(CultureInfo.InvariantCulture, text, jsonObjectContract_0.UnderlyingType)), null);
						}
						if (jsonSerializer_0.missingMemberHandling_0 == MissingMemberHandling.Error)
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Could not find member '{0}' on object of type '{1}'".smethod_1(CultureInfo.InvariantCulture, text, type_0.Name));
						}
						jsonReader_0.Skip();
					}
					goto case JsonToken.Comment;
				}
				case JsonToken.EndObject:
					flag = true;
					goto case JsonToken.Comment;
				default:
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing object: " + jsonReader_0.JsonToken_0);
				}
			}
		}

		private bool method_38(JsonReader jsonReader_0, JsonContract jsonContract_0, bool bool_1)
		{
			if (bool_1)
			{
				return jsonReader_0.Read();
			}
			switch (jsonContract_0?.enum14_0 ?? Enum14.Read)
			{
			default:
				throw new ArgumentOutOfRangeException();
			case Enum14.Read:
				do
				{
					if (!jsonReader_0.Read())
					{
						return false;
					}
				}
				while (jsonReader_0.JsonToken_0 == JsonToken.Comment);
				return true;
			case Enum14.ReadAsInt32:
				jsonReader_0.ReadAsInt32();
				break;
			case Enum14.ReadAsBytes:
				jsonReader_0.ReadAsBytes();
				break;
			case Enum14.ReadAsString:
				jsonReader_0.ReadAsString();
				break;
			case Enum14.ReadAsDecimal:
				jsonReader_0.ReadAsDecimal();
				break;
			case Enum14.ReadAsDateTime:
				jsonReader_0.ReadAsDateTime();
				break;
			case Enum14.ReadAsDateTimeOffset:
				jsonReader_0.ReadAsDateTimeOffset();
				break;
			}
			return jsonReader_0.JsonToken_0 != JsonToken.None;
		}

		public object method_39(JsonReader jsonReader_0, JsonObjectContract jsonObjectContract_0, JsonProperty jsonProperty_0, JsonProperty jsonProperty_1, string string_0, out bool bool_1)
		{
			object obj = null;
			if (!jsonObjectContract_0.bool_5)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Could not create an instance of type {0}. Type is an interface or abstract class and cannot be instantiated.".smethod_0(CultureInfo.InvariantCulture, jsonObjectContract_0.UnderlyingType));
			}
			if (jsonObjectContract_0.OverrideConstructor != null)
			{
				if (jsonObjectContract_0.OverrideConstructor.GetParameters().Length > 0)
				{
					bool_1 = true;
					return method_35(jsonReader_0, jsonObjectContract_0, jsonProperty_0, jsonObjectContract_0.OverrideConstructor, string_0);
				}
				obj = jsonObjectContract_0.OverrideConstructor.Invoke(null);
			}
			else if (jsonObjectContract_0.DefaultCreator != null && (!jsonObjectContract_0.DefaultCreatorNonPublic || jsonSerializer_0.constructorHandling_0 == ConstructorHandling.AllowNonPublicDefaultConstructor || jsonObjectContract_0.ParametrizedConstructor == null))
			{
				obj = jsonObjectContract_0.DefaultCreator();
			}
			else if (jsonObjectContract_0.ParametrizedConstructor != null)
			{
				bool_1 = true;
				return method_35(jsonReader_0, jsonObjectContract_0, jsonProperty_0, jsonObjectContract_0.ParametrizedConstructor, string_0);
			}
			if (obj == null)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Unable to find a constructor to use for type {0}. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute.".smethod_0(CultureInfo.InvariantCulture, jsonObjectContract_0.UnderlyingType));
			}
			bool_1 = false;
			return obj;
		}

		private object method_40(object object_0, JsonReader jsonReader_0, JsonObjectContract jsonObjectContract_0, JsonProperty jsonProperty_0, string string_0)
		{
			method_27(jsonReader_0, jsonObjectContract_0, object_0);
			Dictionary<JsonProperty, Enum16> dictionary_ = ((jsonObjectContract_0.Boolean_0 || method_23(jsonSerializer_0.defaultValueHandling_0, DefaultValueHandling.Populate)) ? jsonObjectContract_0.Properties.ToDictionary((JsonProperty jsonProperty_0) => jsonProperty_0, (JsonProperty jsonProperty_0) => Enum16.None) : null);
			if (string_0 != null)
			{
				method_22(jsonReader_0, string_0, object_0);
			}
			int int32_ = jsonReader_0.Int32_0;
			bool flag = false;
			while (true)
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.PropertyName:
				{
					string text = jsonReader_0.Object_0.ToString();
					try
					{
						JsonProperty closestMatchProperty = jsonObjectContract_0.Properties.GetClosestMatchProperty(text);
						if (closestMatchProperty == null)
						{
							if (itraceWriter_0 != null && itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
							{
								itraceWriter_0.Trace(TraceLevel.Verbose, Struct25.smethod_2(jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, "Could not find member '{0}' on {1}".smethod_1(CultureInfo.InvariantCulture, text, jsonObjectContract_0.UnderlyingType)), null);
							}
							if (jsonSerializer_0.missingMemberHandling_0 == MissingMemberHandling.Error)
							{
								throw JsonSerializationException.smethod_1(jsonReader_0, "Could not find member '{0}' on object of type '{1}'".smethod_1(CultureInfo.InvariantCulture, text, jsonObjectContract_0.UnderlyingType.Name));
							}
							if (jsonReader_0.Read())
							{
								method_41(jsonObjectContract_0, jsonReader_0, text, object_0);
							}
						}
						else
						{
							if (closestMatchProperty.JsonContract_0 == null)
							{
								closestMatchProperty.JsonContract_0 = method_4(closestMatchProperty.PropertyType);
							}
							JsonConverter jsonConverter = method_12(closestMatchProperty.JsonContract_0, closestMatchProperty.MemberConverter, jsonObjectContract_0, jsonProperty_0);
							if (!method_38(jsonReader_0, closestMatchProperty.JsonContract_0, jsonConverter != null))
							{
								throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected end when setting {0}'s value.".smethod_0(CultureInfo.InvariantCulture, text));
							}
							method_43(jsonReader_0, closestMatchProperty, dictionary_);
							if (!method_20(closestMatchProperty, jsonConverter, jsonObjectContract_0, jsonProperty_0, jsonReader_0, object_0))
							{
								method_41(jsonObjectContract_0, jsonReader_0, text, object_0);
							}
						}
					}
					catch (Exception exception_)
					{
						if (!method_2(object_0, jsonObjectContract_0, text, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
						{
							throw;
						}
						method_44(jsonReader_0, bool_1: true, int32_);
					}
					goto case JsonToken.Comment;
				}
				case JsonToken.EndObject:
					flag = true;
					goto case JsonToken.Comment;
				case JsonToken.Comment:
					if (flag || !jsonReader_0.Read())
					{
						if (!flag)
						{
							method_31(jsonReader_0, jsonObjectContract_0, object_0, "Unexpected end when deserializing object.");
						}
						method_42(object_0, jsonReader_0, jsonObjectContract_0, int32_, dictionary_);
						method_28(jsonReader_0, jsonObjectContract_0, object_0);
						return object_0;
					}
					break;
				default:
					throw JsonSerializationException.smethod_1(jsonReader_0, "Unexpected token when deserializing object: " + jsonReader_0.JsonToken_0);
				}
			}
		}

		private void method_41(JsonObjectContract jsonObjectContract_0, JsonReader jsonReader_0, string string_0, object object_0)
		{
			if (jsonObjectContract_0.ExtensionDataSetter != null)
			{
				try
				{
					JToken value = JToken.ReadFrom(jsonReader_0);
					jsonObjectContract_0.ExtensionDataSetter(object_0, string_0, value);
				}
				catch (Exception exception_)
				{
					throw JsonSerializationException.smethod_2(jsonReader_0, "Error setting value in extension data for type '{0}'.".smethod_0(CultureInfo.InvariantCulture, jsonObjectContract_0.UnderlyingType), exception_);
				}
			}
			else
			{
				jsonReader_0.Skip();
			}
		}

		private void method_42(object object_0, JsonReader jsonReader_0, JsonObjectContract jsonObjectContract_0, int int_0, Dictionary<JsonProperty, Enum16> dictionary_0)
		{
			if (dictionary_0 == null)
			{
				return;
			}
			foreach (KeyValuePair<JsonProperty, Enum16> item in dictionary_0)
			{
				JsonProperty key = item.Key;
				Enum16 value = item.Value;
				if (value != 0 && value != Enum16.Null)
				{
					continue;
				}
				try
				{
					Required required = key.nullable_0 ?? jsonObjectContract_0.ItemRequired ?? Required.Default;
					switch (value)
					{
					case Enum16.None:
						if (required != Required.AllowNull && required != Required.Always)
						{
							if (key.JsonContract_0 == null)
							{
								key.JsonContract_0 = method_4(key.PropertyType);
							}
							if (method_23(key.DefaultValueHandling.GetValueOrDefault(jsonSerializer_0.defaultValueHandling_0), DefaultValueHandling.Populate) && key.Writable)
							{
								key.ValueProvider.SetValue(object_0, method_19(jsonReader_0, key.method_1(), CultureInfo.InvariantCulture, key.JsonContract_0, key.PropertyType));
							}
							break;
						}
						throw JsonSerializationException.smethod_1(jsonReader_0, "Required property '{0}' not found in JSON.".smethod_0(CultureInfo.InvariantCulture, key.PropertyName));
					case Enum16.Null:
						if (required == Required.Always)
						{
							throw JsonSerializationException.smethod_1(jsonReader_0, "Required property '{0}' expects a value but got null.".smethod_0(CultureInfo.InvariantCulture, key.PropertyName));
						}
						break;
					}
				}
				catch (Exception exception_)
				{
					if (!method_2(object_0, jsonObjectContract_0, key.PropertyName, jsonReader_0 as IJsonLineInfo, jsonReader_0.String_0, exception_))
					{
						throw;
					}
					method_44(jsonReader_0, bool_1: true, int_0);
				}
			}
		}

		private void method_43(JsonReader jsonReader_0, JsonProperty jsonProperty_0, Dictionary<JsonProperty, Enum16> dictionary_0)
		{
			if (jsonProperty_0 != null && dictionary_0 != null)
			{
				dictionary_0[jsonProperty_0] = ((jsonReader_0.JsonToken_0 == JsonToken.Null || jsonReader_0.JsonToken_0 == JsonToken.Undefined) ? Enum16.Null : Enum16.Value);
			}
		}

		private void method_44(JsonReader jsonReader_0, bool bool_1, int int_0)
		{
			method_1();
			if (bool_1)
			{
				jsonReader_0.Skip();
				while (jsonReader_0.Int32_0 > int_0 + 1 && jsonReader_0.Read())
				{
				}
			}
		}

		[CompilerGenerated]
		private static ParameterInfo smethod_0(ParameterInfo parameterInfo_0)
		{
			return parameterInfo_0;
		}

		[CompilerGenerated]
		private static object smethod_1(ParameterInfo parameterInfo_0)
		{
			return null;
		}

		[CompilerGenerated]
		private static string smethod_2(KeyValuePair<ParameterInfo, object> keyValuePair_0)
		{
			return keyValuePair_0.Key.Name;
		}

		[CompilerGenerated]
		private static JsonProperty smethod_3(JsonProperty jsonProperty_0)
		{
			return jsonProperty_0;
		}

		[CompilerGenerated]
		private static Enum16 smethod_4(JsonProperty jsonProperty_0)
		{
			return Enum16.None;
		}
	}
}
